<?php
include("lib/template.inc");
include("lib/lib_dps.php");
include("nav_data.php");
$m=0;

//$developer=true;
if($dps_link!=FALSE AND $checker=get_current_user_obj())
{
	$select_format='SELECT * FROM confirm WHERE epsn="%s" AND user_ID=%d';
	$query=sprintf($select_format,$checker->epsn,$checker->user_ID);
	if($developer)
		echo("confirm.php:".$query."<br />");
	$res_exist=mysql_query($query,$dps_link);
	if(!($obj_exist=mysql_fetch_object($res_exist)))
	{
		if(isset($_POST["ul_ID"]))
		{
			$delete_format='DELETE FROM upload_cache WHERE ul_ID=%d';
			$query=sprintf($delete_format,$_POST["ul_ID"]);
			if($developer)
				echo($query."<br />");
			$res_nouse=mysql_query($query,$dps_link);
		}
		$select_format='SELECT * FROM upload_cache WHERE epsn=%d AND user_ID=%d';
		$query=sprintf($select_format,$checker->epsn,$checker->user_ID);
		if($developer)
			echo($query."<br />");
		$res_tocheck=mysql_query($query,$dps_link);
		while($obj_tocheck=mysql_fetch_object($res_tocheck))
		{
			$report_format="变量类型:%d<br />标题:%s<br />内容:%s<br />";
			switch($obj_tocheck->upload_type)
			{
				case 1:
					$doc[$m]["processor"]="confirm.php";
					$doc[$m]["submit_name"]="删除此条";
					$doc[$m]["title"]="添加记录";
					$doc[$m]["content"]=sprintf($report_format,$obj_tocheck->var_ID,$obj_tocheck->caption,$obj_tocheck->memo);
					$doc[$m]["content"].='<input type=hidden name=ul_ID value='.$obj_tocheck->ul_ID.'>';
					$doc[$m]["wid"]="100%";
					$m++;
					break;
				case 2:
					$doc[$m]["processor"]="confirm.php";
					$doc[$m]["submit_name"]="删除此条";
					$doc[$m]["title"]="删除记录";
					$doc[$m]["content"]=sprintf($report_format,$obj_tocheck->var_ID,$obj_tocheck->caption,$obj_tocheck->memo);
					$doc[$m]["content"].="(如果标题为空，则所有该类型的变量都会被删除)";
					$doc[$m]["content"].='<input type=hidden name=ul_ID value='.$obj_tocheck->ul_ID.'>';
					$doc[$m]["wid"]="100%";
					$m++;
					break;
				case 3:
					$doc[$m]["processor"]="confirm.php";
					$doc[$m]["submit_name"]="删除此条";
					$doc[$m]["title"]="重置记录";
					$doc[$m]["content"]=sprintf($report_format,$obj_tocheck->var_ID,$obj_tocheck->caption,$obj_tocheck->memo);
					$doc[$m]["content"].='<input type=hidden name=ul_ID value='.$obj_tocheck->ul_ID.'>';
					$doc[$m]["wid"]="100%";
					$m++;
					break;
				default:
					$doc[$m]["processor"]="confirm.php";
					$doc[$m]["submit_name"]="删除此条";
					$doc[$m]["title"]="不明操作";
					$doc[$m]["content"]="无效";
					$doc[$m]["content"].='<input type=hidden name=ul_ID value='.$obj_tocheck->ul_ID.'>';
					$doc[$m]["wid"]="100%";
					$m++;
			}
		}
		$doc[$m]["processor"]="confirm_upload_processor.php";
		$doc[$m]["submit_name"]="保存";
		$doc[$m]["title"]="确认上传保存";
		$doc[$m]["content"]='请输入您的密码<input type="password" name="password" size=8><br />再次输入您的密码<input type="password" name="password2" size=8><br />(您确认操作之后，您的信息一会儿后将会自动保存到您的CCR数据库)';
		$doc[$m]["wid"]="100%";
		$m++;
	}
	else
	{
		$doc[$m]["title"]="无需确认";
		$doc[$m]["content"]='您已经提交了保存请求,但是现在您的信息暂时还未与CCR同步。您无须再次确认保存。<br />在下次同步之前您的操作一样会被保存。如果出于安全考虑，您也可以要求<a href="dps_upload.php">立刻同步</a>您的信息(可能需要等待一段时间)。';
		$doc[$m]["wid"]="100%";
		$m++;
	}
}
else
{
		$doc[$m]["title"]="请先登录";
		$doc[$m]["content"]='您必须先<a href=user_login.php>登录DistRema平台</a>才能保存信息。';
		$doc[$m]["wid"]="100%";
		$m++;
}
include("render.php");
render("保存到CCR",$nav_title,$nav_link,$doc);
?>